package com.zero.insp.views;

import com.zero.insp.domain.TUserInfo;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

@Data
@NoArgsConstructor
public class User implements Serializable {
    private static final long serialVersionUID = 1L;

    public User(TUserInfo userDB){
        this.uid = userDB.getId();
        this.uname = userDB.getAccount();
        this.nick = userDB.getName();
        this.type = userDB.getType();
        this.pwd = userDB.getPwd();
        this.salt = userDB.getSalt();
        this.created = userDB.getCreateTime();
        this.updated = userDB.getLoginTime();
    }

    private Long uid;       // 用户id
    private String uname;   // 登录名，不可改
    private String type;   // 用户类型
    private String nick;    // 用户昵称，可改
    private String pwd;     // 已加密的登录密码
    private String salt;    // 加密盐值
    private Date created;   // 创建时间
    private Date updated;   // 修改时间
    private Set<String> roles = new HashSet<>();    //用户所有角色值，用于shiro做角色权限的判断
    private Set<String> perms = new HashSet<>();    //用户所有权限值，用于shiro做资源权限的判断
}
